var app = getApp()
const util = require('../../utils/util.js');
const api = require('../../config/api.js');
const user = require('../../utils/user.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {
    checkboxItems: [
      { checked: false, color: '#fff' },
      { checked: true, color: '#43cbc9' },
      { checked: false, color: '#fff' }
    ],

    isAgree: false,

  },


  //条款同意
  bindAgreeChange: function (e) {
    this.setData({
      isAgree: !!e.detail.value.length
    });
  },

  //改变按摩套餐
  changePrfr: function () {
    var that = this
    that.pircese(0)
  },

  changePrsc: function () {
    var that = this
    that.pircese(1)
  },

  changePrth: function () {
    var that = this
    that.pircese(2)
  },

  pircese: function (x) {
    var that = this
    var checkboxItems = that.data.checkboxItems;
    if (!checkboxItems[x].checked) {
      for (var i = 0; i < checkboxItems.length; i++) {
        if (i == x) {
          checkboxItems[i].checked = true
          checkboxItems[i].color = '#43cbc9'
        } else {
          checkboxItems[i].checked = false
          checkboxItems[i].color = '#fff'
        }
      }
    }
    that.setData({
      checkboxItems: checkboxItems
    });
  },

  //付款
  Payser: function () {
    wx.showToast({
      title: '支付成功',
      icon: 'success',
      duration: 2000
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})